'use strict';

const Controller = require('egg').Controller;

class ListsController extends Controller {
    async getlist() {
        const { ctx } = this;
        const {pageIndex,pageSize,type}=ctx.query
        let sql=`SELECT * FROM movie WHERE type like '%${type}%' LIMIT ${pageIndex},${pageSize}`

        let totalsql=`SELECT * FROM movie WHERE type like '%${type}%'`
        const data=await this.app.mysql.query(sql)
        const total=await this.app.mysql.query(totalsql)
        ctx.body={
            code:200,
            data,
            total:total.length
        }
    }
}

module.exports = ListsController;
